
using Game.Framework.FState;

namespace Game.Framework.UI
{
    public class UIStateOpen<T> : UIStateBase where T : UIStateNormal, new()
    {
        private float _endTime;

        public override void Enter(StateData param)
        {
            base.Enter(param);

            if (_data.view.HasDirector)
            {
                _endTime = _data.view.OpenTimelineTime;
            }
            else
            {
                _endTime = _data.view.PlayOpenAnim();
            }
        }

        public override void FixedUpdate(float deltaTime)
        {
            base.FixedUpdate(deltaTime);

            if (_elapsedTime >= _endTime)
            {
                ChangeState<T>(new UIStateData(_data.view));
            }
        }
    }
}